home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / printing / save print record / saveaprintrecord.p < prev   
Encoding:
Text File  |  2000-06-23  |  2.7 KB  |  93 lines

  1. {
  2.     File:        SaveAPrintRecord.p
  3.  
  4.     Contains:    Save a Print Record:  Walks you through the style and job dialogs to create a
  5.                 print record ready-to-print-with, and then saves it to a resource file with
  6.                 resource type 'YO!!' and ID 128.  The first step towards saving print records
  7.                 for multiple printers so you can set your favorite parameters before printing,
  8.                 since there's no API to do most of it.
  9.  
  10.     Written by:     
  11.  
  12.     Copyright:    Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
  13.  
  14.                 You may incorporate this Apple sample source code into your program(s) without
  15.                 restriction. This Apple sample source code has been provided "AS IS" and the
  16.                 responsibility for its operation is yours. You are not permitted to redistribute
  17.                 this Apple sample source code as "Apple sample source code" after having made
  18.                 changes. If you're going to re-distribute the source, we require that you make
  19.                 it clear in the source that the code was descended from Apple sample source
  20.                 code, but that you've made changes.
  21.  
  22.     Change History (most recent first):
  23.                 7/26/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  24.                 
  25.  
  26. }
  27.  
  28. {------------------------------------------------------------------------------}
  29.  
  30.  
  31. {$I-}
  32. program Sample;
  33.  
  34.  
  35. uses
  36.     Traps, Printing, StandardFile,Fonts,Quickdraw,Menus,TextEdit,Dialogs,Resources,Sound;
  37.  
  38. procedure Initialize;
  39.  
  40.     var
  41.         ignoreResult: BOOLEAN;
  42.         ourPrintRecord: THPrint;
  43.         ourReply: StandardFileReply;
  44.         ourOSErr: OSErr;
  45.         ourResRefNum: integer;
  46.  
  47.  
  48.     begin
  49.         InitGraf(@qd.thePort);
  50.         InitFonts;
  51.         InitWindows;
  52.         InitMenus;
  53.         TEInit;
  54.         InitDialogs(nil);
  55.         InitCursor;
  56.  
  57.         PrOpen;
  58.         ourPrintRecord := THPrint(NewHandle(SIZEOF(TPrint)));
  59.         PrintDefault(ourPrintRecord);
  60.         ignoreResult := PrStlDialog(ourPrintRecord);
  61.         ignoreResult := PrJobDialog(ourPrintRecord);
  62.  
  63.         StandardPutFile('Save print record file as', 'My Print Record', ourReply);
  64.         ourOSErr := noErr;
  65.         if ourReply.sfGood then  {Did the user accept a file to save as?}
  66.             begin
  67.                 if ourReply.sfReplacing then
  68.                     ourOSErr := FSpDelete(ourReply.sfFile);    { make sure this is gone before we start! }
  69.                 if ourOSErr = noErr then
  70.                     begin
  71.                         FSpCreateResFile(ourReply.sfFile, 'RSED', 'RSRC', ourReply.sfScript);
  72.                         ourResRefNum := FSpOpenResFile(ourReply.sfFile, fsWrPerm);
  73.                         AddResource(Handle(ourPrintRecord), 'YO!!', 128, 'Saved print record');
  74.                         CloseResFile(ourResRefNum);
  75.                     end
  76.                 else
  77.                     SysBeep(10);
  78.             end;
  79.     end;
  80.  
  81.  
  82. begin
  83.  
  84.         {1.01 - call to ForceEnvirons removed}
  85.         {If you have stack requirements that differ from the default,}
  86.         {      then you could use SetApplLimit to increase StackSpace at }
  87.         {      this point, before calling MaxApplZone.}
  88.  
  89.     MaxApplZone; {expand the heap so code segments load at the top}
  90.  
  91.     Initialize; {initialize the program}
  92.     ExitToShell;
  93. end.